    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<load href="__PUBLIC__/Js/jquery.js" /> 
<load href='__PUBLIC__/Css/flexigrid.css' />  
<load href='__PUBLIC__/Css/thickbox.css' /> 
<load href="__PUBLIC__/Js/flexigrid.js" /> 
<load href="__PUBLIC__/Js/thickbox.js" />  
 
</head>
<body>
<a id="add" style="display:none" href="__URL__/add/?keepThis=true&TB_iframe=true&height=100%&width=100%" title="新增数据" class="thickbox"></a>  
<a id="edit" style="display:none"  href="__URL__/edit/id/{id}//?keepThis=true&TB_iframe=true&height=100%&width=100%" title="修改数据" class="thickbox"></a>  
<a id="delete" style="display:none"  href="__URL__/delete/id/{id}//?keepThis=true&TB_iframe=true&height=100%&width=100%" title="删除数据" class="thickbox"></a>  
 
<table id="flex1" style="display:none"></table>

<script type="text/javascript">



            $("#flex1").flexigrid
            (
            {
            url: 'json',
            dataType: 'json',
            //searchField对应数据库里的字段,多个字段用逗号隔开,同时可以自定搜索服务端的buildWhere方法,id为查询按钮的id必填,onpress为自定义钮的方法一般为空,name为查询按钮显示给用户我名称
            //filter:{filter:"<div class='fbutton'><span>邮箱<input type='text'/></span><span id='abc'>查询</span></div>",name:'查询',searchField:"email,title,content",onpress:flexCommand,id:'abc'},
            colModel : [
                {display: 'role_id', name : 'role_id', width : 40, sortable : true, align: 'left'},{display: 'node_id', name : 'node_id', width : 40, sortable : true, align: 'left'},{display: 'level', name : 'level', width : 40, sortable : true, align: 'left'},{display: 'pid', name : 'pid', width : 40, sortable : true, align: 'left'},{display: 'module', name : 'module', width : 40, sortable : true, align: 'left'}
                ],
            buttons : [
                {name: '增加', bclass: 'add', onpress : flexCommand},
                {name: '删除', bclass: 'delete', onpress : flexCommand},
                {name: '编辑', bclass: 'edit', onpress : flexCommand},
                {separator: true}
                ],
            searchitems : [
                {display: 'role_id', name : 'role_id'},{display: 'node_id', name : 'node_id'},{display: 'level', name : 'level'},{display: 'pid', name : 'pid'},{display: 'module', name : 'module'}
                ],
            sortname: "role_id",
            sortorder: "asc",
            usepager: true,
            title: 'Access',
            useRp: true,
            rp: 15,
            showTableToggleBtn: true,
            width: 700,
            height: 200,
            pagestat: '显示从 {from} 到 {to} 共 {total} 条记录',
            procmsg: '数据加载中...',
            nomsg: '没找到相关记录.',
            errormsg: '连接出错.'
            }
            );
            
           function flexCommand(com,grid)
            {
              var id="";
              
               for(var i=0;i<$('.trSelected',grid).length;i++)
               {
                   id+=$('.trSelected',grid).get(i).id.substring(3)+",";
               }
                if(id.length>0)id=id.substring(0,id.length-1);
                if (com=='删除')
                    {   
                        //confirm('Delete ' + $('.trSelected',grid).length + ' items?')
                       if( $('.trSelected',grid).length ==0)
                       {
                          alert('请选择要删除的项');
                       }
                       else
                       {
                         var yes=  confirm('确认删除已选中的 ' + $('.trSelected',grid).length + ' 项吗?')
                         {
                           if(yes)
                           {
                             var url="__URL__/delete/id/{id}//?keepThis=true&TB_iframe=true&height=100%&width=100%";
                              $("#delete").attr("href",url.replace(/\{id\}/,id)); 
                              $("#delete").trigger("click") 
                              
                              //tb_remove();
                              //flexReload();
                               
                             
                           }
                         }
                       }
                    }
                else if (com=='增加')
                    {
                       
                      $("#add").trigger("click")
                   
                    } 
                else if (com=='编辑')
                    {
                       if( $('.trSelected',grid).length ==0)
                       {
                          alert('请选择要编辑的项');
                       }
                       else
                       {
                              if( $('.trSelected',grid).length >1)
                              {
                                  alert('请选择其中1项,你已经选择了'+$('.trSelected',grid).length+"项"); 
                              }
                              else
                              {
                                  var url="__URL__/edit/id/{id}//?keepThis=true&TB_iframe=true&height=100%&width=100%";
                                  $("#edit").attr("href",url.replace(/\{id\}/,id)); 
                                  $("#edit").trigger("click") 
                              }

                       }
                    } 
                  else if ("查询"==com)
                    {
                    // debugger;
                   var sValue= $('input[type=text]',$(".tDiv",grid)).eq(0).val();
                        alert(sValue);
                    }            
            }
       /*
        $('b.top').click
        (
            function ()
                {
                    $(this).parent().toggleClass('fh');
                }
        );
         */
            function flexReload()
            {
            $("#flex1").flexReload();
            }  
</script>
</body>
</html>

